package com.neuronbit.businessflow.runtime;

import lombok.Getter;
import lombok.Setter;

import java.util.HashSet;
import java.util.Set;

/**
 * The Flow context.
 */
public abstract class FlowContext {
    private Set<String> succeededStepIds = new HashSet<>();
    @Getter
    @Setter
    private String executionId;

    /**
     * Should run a step.
     *
     * @param step the step
     * @return the boolean
     */
    public boolean shouldRun(Step<?> step) {
        return !succeededStepIds.contains(step.getId());
    }

    public void addSucceededStep(Step<?> step) {
        if (null != step) {
            succeededStepIds.add(step.getId());
        }
    }
}
